package com.basedefence;

import com.badlogic.gdx.math.Vector2;
import com.e3roid.util.MathUtil;

import android.graphics.Point;

public class Utils {
	public static Point getValueBetweenPoints (long currTime, long maxTime, Point startPoint, Point endPoint)
	{
		return getValueBetweenPoints(currTime, maxTime, startPoint, endPoint, new Point());
	}
	
	public static Point getValueBetweenPoints (long currTime, long maxTime, Point startPoint, Point endPoint, Point result)
	{
		int newX = (int) (startPoint.x + (endPoint.x - startPoint.x) * currTime / maxTime);
		int newY = (int) (startPoint.y + (endPoint.y - startPoint.y) * currTime / maxTime);
		result.set(newX, newY);
		return result;
	}
	
	public static float direction2Angle (float x, float y)
	{
		float res = (float) Math.atan2(y, x);
		
		res = MathUtil.radToDeg(res);
		
		return res;
	}
	
	public static Vector2 angle2Direction (float angle)
	{
		float x = (float) Math.cos(MathUtil.degToRad(angle));
		float y = (float) Math.sin(MathUtil.degToRad(angle));
		Vector2 direction = new Vector2(x, y);
		return direction.nor();
	}
	
//	public static float radian2Degree (double radian	)
//	{
//		return (float) ((180 * radian) / Math.PI);
//	}
//	
//	public static float degree2Radian (double radian	)
//	{
//		return (float) ((Math.PI * radian) / 180.0);
//	}
}
